<script>
export default {
  name: "CView"
}
</script>

<template>
  <h1>双向绑定指令</h1>
<!--  -->
<!--  -->
  <input type="text" v-model="info">
  {{info}}
  <hr>
  <h3>用户登录</h3>
  <input type="text" placeholder="请输入用户名" v-model="user.username">
  <input type="password" placeholder="请输入密码" v-model="user.password">
  <br>
  性别:
  <input type="radio" name="gender" value="1" v-model="user.gender">男
  <input type="radio" name="gender" value="0" v-model="user.gender">女
  <button @click="login">登录</button>
</template>
<script setup>
import {ref} from "vue";

const info = ref("双向绑定");

const user = ref({
  username: "",
  password: "",
  gender: ""
});
const login = () => {
  console.log(user.value);
  console.log(user.value.username);
  console.log(user.value.password);
  console.log(user.value.gender);
}
</script>

<style scoped>

</style>